﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MyCourseManageProject.UI
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            //this.StartPosition = FormStartPosition.CenterScreen;//窗体居中显示  
            //this.MaximizeBox = false;//不显示最大化按钮 
            //this.FormBorderStyle = FormBorderStyle.FixedSingle;//禁止放大缩小
            
            InitializeComponent();
            //显示当前登录用户名
            this.lblCurrentUser.Text = Program.currentTeacher.TeacherName;
            //如果有权限信息,则在这个地方设置权限...

        }

        private void FrmMain_Load(object sender, EventArgs e)
        {

        }


        /// <summary>
        /// 嵌入子窗体的通用方法
        /// </summary>
        private void OPenForm(Form frm)
        { 
        
         //首先判断是否已经嵌入其他窗体
            foreach (Control item in this.splitContainer2.Panel2.Controls)
            {
                if (item is Form){
                    ((Form)item).Close();
                }
            }
            //嵌入新的子窗体(需要将子窗体设置为非顶级控件)
            frm.TopLevel = false;
            //去掉子窗体的边框(目前已去掉,可以不写)
            frm.FormBorderStyle = FormBorderStyle.None;
            frm.Parent = this.splitContainer2.Panel2;//设置窗体容器
            frm.Dock = DockStyle.Fill;//随着容器大小自动调整对应大小
            frm.Show();
        }

        /// <summary>
        ///课程信息管理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInfo_Click(object sender, EventArgs e)
        {
            this.OPenForm(new FrmCourseManage());
        }
        /// <summary>
        /// 讲师信息管理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnTeacherInfo_Click(object sender, EventArgs e)
        {
            this.OPenForm(new FrmTeacherManage());
        }
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPwd_Click(object sender, EventArgs e)
        {
            this.OPenForm(new FrmModifyPwd());
        }

        /// <summary>
        /// 添加课程信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void btnAdd_Click_1(object sender, EventArgs e)
        {
            this.OPenForm(new FrmAddCourse());
        }


        private void button1_Click(object sender, EventArgs e)
        {
            this.OPenForm(new FrmOther());
        }
    }
}
